﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace ORM.NHibernateDemo.Test
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            var arry = new int[]
            {
                0,1,1,2,3,5,8,13,21,34,55,89,144
            };
            for (int i = 0; i < arry.Length; i++)
            {
                var t = CalcFibonacci(i);
                Assert.IsTrue(t == arry[i]);
            }
            for (int i = 0; i < 30; i++)
            {
                var t = CalcFibonacci(i);
                Console.Write(t+",");
            }
        }

        /// <summary>
        /// 计算斐波那契数列
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public static int CalcFibonacci(int x)
        {
            if (x == 0)
                return 0;
            if (x == 1)
                return 1;
            x--;
            return CalcFibonacci(x) + CalcFibonacci(x - 1);
        }
    }
}
